package utils.time
{
	public class TimeFormat
	{
		public function TimeFormat()
		{
		}
		
		/**
		 *以"mm:ss"的格式返回时间 
		 * @param t
		 * @return 
		 * 
		 */		
		public static function formatMMSS(second:uint):String
		{
			var m:String = int(second/60)+"";
			var s:String = second%60+"";
			if(m.length<2)
				m = "0" + m;
			if(s.length<2)
				s = "0" + s;
			return m + ":" + s;
		}
		
		/**
		 * 以"hh:mm:ss"的格式返回时间 
		 * @param t
		 * @return 
		 * 
		 */		

		public static function formatHHMMSS(second:uint, splitTag:String=":"):String
		{
			var h:String = int(second/60/60)+"";
			var m:String = (int(second/60) - int(h)*60) + "";
			var s:String = second%60+"";
			if(h.length<2)
				h = "0" + h;
			if(m.length<2)
				m = "0" + m;
			if(s.length<2)
				s = "0" + s;
			return h + splitTag +m + splitTag + s;
		}
		
		public static function formatDDHHMMSS(second:uint, splitTag:String=":"):String
		{
			var lessTime:uint = second;
			var d:String = "";
			var h:String = "";
			var m:String = "";
			var s:String = "";
			
			d = int(lessTime/60/60/24)+"";
			lessTime -= int(d)*24*60*60;
			if(lessTime>0)
				h = int(lessTime/60/60)+"";
			lessTime -= int(h)*60*60;
			if(lessTime>0)
				m = int(lessTime/60) + "";
			lessTime -= int(m)*60;
			if(lessTime>0)
				s = second%60+"";
			
			if(d.length<2)
				d = "0" + d;
			if(h.length<2)
				h = "0" + h;
			if(m.length<2)
				m = "0" + m;
			if(s.length<2)
				s = "0" + s;
			return d + splitTag + h + splitTag +m + splitTag + s;
		}

//		public static function formatHHMMSS(time:Number, insertHout:String = ":", insertMinute:String = ":"):String {
//			var hour:uint = time / 60 / 60 >> 0;
//			var minute:uint = (time / 60) % 60;
//			var second:uint = time % 60;
//			var timeTxt:String = "";
//			timeTxt += ((hour > 100) ? hour.toString() : (100 + hour).toString().substr(1)) + insertHout;
//			timeTxt += ((minute < 10) ? ("0" + minute.toString()) : minute.toString()) + insertMinute;
//			timeTxt += (second < 10) ? ("0" + second.toString()) : second.toString();            
//			return timeTxt;
//
//		}

	}
}